#!/bin/sh
cgroup=/sys/fs/cgroup/elogind

mkdir -p "$cgroup"
if ! mountpoint "$cgroup" > /dev/null 2>&1; then
    mount -t cgroup -o none,name=elogind cgroup $cgroup || exit 1
fi

for tmpfs in /run/systemd /run/user; do
    mountpoint "$tmpfs" > /dev/null 2>&1 && continue
    mkdir -p "$tmpfs"
    mount -t tmpfs -o nosuid,nodev,noexec,mode=0755 none "$tmpfs" || exit 1
done

exec /usr/libexec/elogind/elogind
